﻿#include <iostream>

using namespace std;
#include "Teacher01.hpp"
#include "EnglishTeacher01.hpp"
#include "ChineseTeacher01.hpp"

#include <vector>
#include<algorithm>

bool compare(Teacher01& a,Teacher01& b)
{
	return a>b;
}

int main(int argc, char* argv[])
{
	cout<<"int vector"<<endl;
	vector<int> vi;
	vi.push_back(1);
	vi.push_back(2);
	vi.push_back(3);
	vi.push_back(4);

	cout<<"at 遍历"<<endl;
	for (int i = 0; i < vi.size(); i++)
	{
		cout<<vi.at(i)<<" ";
	}
	cout << endl;

	cout<<"iterator 遍历"<<endl;
	for (vector<int>::iterator it = vi.begin(); it != vi.end(); it++)
	{
		cout<<*it<<" ";
	}
	cout << endl;


	cout<<"teacher vector"<<endl;
	vector<Teacher01> vTeacher;

	ChineseTeacher01 ct1(29, "tim", TEACHER_SEX_FEMALE, 30000, TEACHER_GRADE_C, 'A');
	EnglishTeacher01 et1(30, "bob", TEACHER_SEX_MAMLE, 40000, TEACHER_GRADE_B, 'B');
	ChineseTeacher01 ct2(31, "tom", TEACHER_SEX_MAMLE, 50000, TEACHER_GRADE_D, 'C');
	EnglishTeacher01 et2(32, "jack", TEACHER_SEX_FEMALE, 60000, TEACHER_GRADE_A, 'A');

	vTeacher.push_back(ct1);
	vTeacher.push_back(et1);
	vTeacher.push_back(ct2);
	vTeacher.push_back(et2);

	cout<<"at 遍历"<<endl;
	for (int i = 0; i < vTeacher.size(); i++)
	{
		cout<<vTeacher.at(i)<<" ";
	}
	cout << endl;

	cout<<"iterator 遍历"<<endl;
	for (vector<Teacher01>::iterator it = vTeacher.begin(); it != vTeacher.end(); it++)
	{
		cout<<*it<<" ";
	}
	cout << endl;



	sort(vTeacher.begin(), vTeacher.end(), compare);
	cout<<"按教师级别降序排列 iterator 遍历"<<endl;
	for (vector<Teacher01>::iterator it = vTeacher.begin(); it != vTeacher.end(); it++)
	{
		cout<<*it<<" ";
	}
	cout << endl;

	cout <<argv[0]<<endl;
	system("pause");
	return 0;
}